package game.controller
{
	import game.constants.ApplicationNotification;
	import game.model.building.BuildingConfigProxy;
	import game.model.building.BuildingProxy;
	import game.model.gameEvent.GameEventProxy;
	import game.model.globalVar.GlobalVarProxy;
	import game.model.items.InventoryProxy;
	import game.model.items.ItemProxy;
	import game.model.net.NetProxy;
	import game.model.player.PlayerProxy;
	import game.model.texture.TextureProxy;
	import game.model.time.TimeProxy;
	import game.view.mediator.ApplicationMediator;
	import game.view.mediator.GameBoardMediator;
	import game.view.mediator.MenuMediator;
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.command.SimpleCommand;
	
	/**
	 * ...
	 * @author Thot
	 */
	
	public class StartApplicationCommand extends SimpleCommand
	{
		override public function execute( notification:INotification ):void
		{
			_registerProxies();
			_registerMediators();
			sendNotification( ApplicationNotification.LOAD_GAME_DATA );
		}
		
		private function _registerProxies():void
		{
			var netProxy:NetProxy						= new NetProxy();
			var timeProxy:TimeProxy						= new TimeProxy();
			var itemProxy:ItemProxy 					= new ItemProxy();
			var playerProxy:PlayerProxy 				= new PlayerProxy();
			var textureProxy:TextureProxy 				= new TextureProxy();
			var buildProxy:BuildingProxy 				= new BuildingProxy();
			var gameEventProxy:GameEventProxy 			= new GameEventProxy();
			var inventoryProxy:InventoryProxy 			= new InventoryProxy();
			var globalVarProxy:GlobalVarProxy 			= new GlobalVarProxy();
			var buildConfigProxy:BuildingConfigProxy 	= new BuildingConfigProxy();
			
			facade.registerProxy( netProxy );
			facade.registerProxy( timeProxy );
			facade.registerProxy( playerProxy );
			facade.registerProxy( buildConfigProxy );
			facade.registerProxy( buildProxy );
			facade.registerProxy( textureProxy );
			facade.registerProxy( globalVarProxy );
			facade.registerProxy( itemProxy );
			facade.registerProxy( gameEventProxy );
			facade.registerProxy( inventoryProxy );
		}
		
		private function _registerMediators():void
		{
			var appMediator:ApplicationMediator		= new ApplicationMediator();
			var menuMediator:MenuMediator			= new MenuMediator( appMediator.getMenu() );
			var boardMediator:GameBoardMediator		= new GameBoardMediator( appMediator.getBoard() );
			facade.registerMediator( appMediator );
			facade.registerMediator( menuMediator );
			facade.registerMediator( boardMediator );
		}
	}

}